package com.ude.pim.controller;

import com.ude.pim.common.R;
import com.ude.pim.entity.Demand;
import com.ude.pim.service.DemandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/demand")
public class DemandController {
    @Autowired
    private DemandService demandService;

    @GetMapping("/list")
    public R<List<Demand>> list(){
        return R.success(demandService.list());
    }

    @PostMapping
    public R<String> save(@RequestBody Demand demand){
        demandService.save(demand);
        return R.success("保存成功");
    }

    @DeleteMapping
    public R<String> delete(@RequestBody Demand demand){
        demandService.removeById(demand.getId());
        return R.success("删除成功");
    }
}
